<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
// 应用公共文件

function zbcjson($data = true, $msg = '', $code = 0, $httpState = 200)
{
    return json(array(
        "code" => $code,
        "msg" => $msg,
        "data" => $data
    ), $httpState);
}

function pagejson($data, $count, $msg = "", $code = 0, $httpState = 200)
{
    return json(array(
        "count" => $count,
        "code" => $code,
        "msg" => $msg,
        "data" => $data
    ), $httpState);
}

/**
 * 对称加密
 */
function encrypt($data)
{
    $method = config('aes.method');
    $key = config('aes.key');
    $iv = config('aes.iv');
    $options = config('aes.options');
    return openssl_encrypt($data, $method, $key, $options, $iv);
}

/**
 * 对称解密
 */
function decrypt($data)
{
    $method = config('aes.method');
    $key = config('aes.key');
    $iv = config('aes.iv');
    $options = config('aes.options');
    return openssl_decrypt($data, $method, $key, $options, $iv);
}
